package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.DmcPatrolRecordMapper;
import com.csun.cmny.provider.model.domain.DmcPatrolRecord;
import com.csun.cmny.provider.model.dto.patrol.PatrolRecordQueryDto;
import com.csun.cmny.provider.model.vo.patrol.PatrolRecordVo;
import com.csun.cmny.provider.service.DmcPatrolRecordService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2021/7/22 9:42
 * @Description: 巡更记录接口实现
 */
@Service
public class DmcPatrolRecordServiceImpl extends BaseService<DmcPatrolRecord>
        implements DmcPatrolRecordService {

    @Resource
    private DmcPatrolRecordMapper dmcPatrolRecordMapper;

    /**
     * 巡更记录分页查询
     *
     * @param patrolRecordQueryDto  the patrol record query dto
     *
     * @return  the patrol record vo list.
     */
    @Override
    public List<PatrolRecordVo> queryListWithPage(PatrolRecordQueryDto patrolRecordQueryDto) {

        PageHelper.startPage(patrolRecordQueryDto.getPageNum(), patrolRecordQueryDto.getPageSize());

        return dmcPatrolRecordMapper.queryListWithPage(patrolRecordQueryDto);
    }

    /**
     * 巡更条数
     *
     * @param patrolRecordQueryDto  the patrol record query dto
     *
     * @return  the int.
     */
    @Override
    public Integer queryCount(PatrolRecordQueryDto patrolRecordQueryDto) {

        return dmcPatrolRecordMapper.queryCount(patrolRecordQueryDto);
    }

    /*
    * 根据巡更棒id删除巡更记录
    * */
    @Override
    public void deleteByPatrolId(Long deviceId) {
        dmcPatrolRecordMapper.deleteByPatrolId(deviceId);
    }
    /*
    * 根据巡更点id删除巡更记录
    * */
    @Override
    public void deleteByPointId(Long deviceId) {
        dmcPatrolRecordMapper.deleteByPointId(deviceId);
    }
}
